# Maintainer: Andreas Radke <andyrtr@archlinux.org>

pkgname=pappl
pkgver=1.3.2
pkgrel=1
pkgdesc="a simple C-based framework/library for developing CUPS Printer Applications"
arch=('x86_64')
url="https://www.msweet.org/pappl/"
license=('Apache' 'custom')
depends=('libcups' 'libjpeg-turbo' 'pam')
makedepends=('git')
source=(https://github.com/michaelrsweet/pappl/releases/download/v${pkgver}/${pkgname}-${pkgver}.tar.gz{,.sig})
sha256sums=('c3d8febb56367940dd4c26e794fc5014abe8cd6ff0a63d1ce9e2c9089ce361c5'
            'SKIP')
validpgpkeys=('845464660B686AAB36540B6F999559A027815955') # "Michael R Sweet <michael.r.sweet@gmail.com>"
#validpgpkeys=('9086C3CDC66C3F563CF8F405BE67C75EC81F3244') # Michael R Sweet <msweet@msweet.org>

build() {
  cd "$pkgname-$pkgver"

  # The build system uses only DSOFLAGS but not LDFLAGS to build some libraries.
  export DSOFLAGS=${LDFLAGS}

  ./configure --prefix=/usr
  make
}

check() {
  cd "$pkgname-$pkgver"
  #make check

  # there's currently  no real test suite, 
  # the tool is only useful outside the fakeroot envireonment - when packaging it crashes:
  # testpappl: client.c:771: avahi_client_get_host_name_fqdn: Assertion `client' failed.
  # /startdir/PKGBUILD: line 43:  1878 Aborted                 (core dumped) ./testsuite/testpappl

  # run it later outside fakeroot!
  #./testsuite/testpappl 
}

package() {
  cd "$pkgname-$pkgver"
  make DESTDIR="$pkgdir/" install

  # install the testing tool
  install -Dm755 testsuite/testpappl -t "$pkgdir"/usr/bin
  # install docs
  install -Dm644 doc/* -t "$pkgdir"/usr/share/doc/$pkgname
  # add license + exception
  install -m644 -Dt "${pkgdir}/usr/share/licenses/${pkgname}" {LICENSE,NOTICE}
}
